home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS in a Box 7
/
BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso
/
Files
/
Util
/
B
/
Bench.cpt
/
Bench
/
DiskBench.asm
next >
Wrap
Assembly Source File
|
1992-03-24
|
6KB
|
268 lines
; DiskBench.Asm 25-Mar-86 Steve Brecher
;
; Version 1.0 ;run on DataFrame at LA MUG meeting 20-Mar-86
; Version 1.1 ;fix DITL resource ID in ALRT 130 (error alert)
; ;provide Rmaker file so Consulair linker not needed
; Version 2.0 ;bug fix: change _NewPtr to _NewHandle
; Version 3.0 ;Ephraim Vishniac April 9, 1986
; ;Dither between operations to remove bias
;
; This program does a performance test on the volume from which it is launched:
; Data transfer speed:
; 32KB reads from start of volume
; 32KB writes to start of volume
; (32KB is choosen as a reasonably-large size that is not likely
; to cross a cylinder boundary).
; Access time:
; 1 512-byte read from block 0 followed by 1 512-byte read
; from offset 1MB (volume must be at least 1MB+512bytes large)
;
; Each test is performed multiple times.
;
; The write tests use the data that was previously read, so the test is
; non-destructive.
Include MacTraps.D
Include SysEqu.D
Include FSEqu.D
XferSize Equ 32*1024
WaitDlogID Equ 128
ResultsDlogID Equ 129
ErrorAlertID Equ 130
TransferCount Equ 100 ;number of times to perform data transfer tests
AccessCount Equ 40 ;number of times to perform access time test
;
; Global variables
;
DlogPtr DS.L 1 ;pointer to dialog record
BuffHndl DS.L 1 ;handle to I/O buffer
ioPB DS.B ioQElSize ;I/O parameter block
XferRdTicks DS.L 1 ;ticks for data transfer test, reads
XferWtTicks DS.L 1 ;ticks for data transfer test, writes
AccessTicks DS.L 1 ;ticks for access time test
XferRdStr DS.B 8 ;strings for ASCII results...
XferWtStr DS.B 8
AccessStr DS.B 8
ErrorStr DS.B 8 ;string for error code
SkipAccess DS.B 1 ;flag to skip access tests if volume too small
XDEF Start
Start: MoveQ #0,D0
SubQ #1,D0 ;all-events mask
_FlushEvents
Pea -4(A5)
_InitGraf
_InitFonts
_InitWindows
_TEInit
Clr.L -(SP)
_InitDialogs
SubQ #4,SP ;put up "Please wait" dialog...
Move #WaitDlogID,-(SP)
Clr.L -(SP)
MoveQ #-1,D0
Move.L D0,-(SP)
_GetNewDialog
Move.L (SP),DlogPtr(A5)
Move.L (SP),-(SP)
Move.L (SP),-(SP)
Move.L (SP),-(SP)
_BeginUpdate
_DrawDialog
_EndUpdate
Move.L #XferSize,D0 ;get reloc block for I/O buffer...
_NewHandle
Bne Error
Move.L A0,BuffHndl(A5)
Move.L Time,D0 ;use time for random number seed
Move.L D0,RndSeed
;
; Get disk driver refNum and default volume's drive number into ioPB
;
Move.L FCBsPtr,A0
Add CurApRefNum,A0 ;pointer to this application file's FCB
Move.L fcbVPtr(A0),A0 ;pointer to VCB
Move vcbDRefNum(A0),ioPB+ioRefNum(A5)
Move vcbDrvNum(A0),ioPB+ioDrvNum(A5)
;
; Set flag to skip access test if volume too small
;
Clr.B SkipAccess(A5) ;assume large enough
Tst.W vcbAlBlkSiz(A0) ;if alloc block size > 64KB...
Bne.S Setup ;then assume volume large enough
Move.L vcbAlBlkSiz(A0),D0
Mulu vcbNmAlBlks(A0),D0 ;byte size of volume
Cmp.L #(1024*1024)+512,D0
Slo SkipAccess(A5)
;
; Set up rest of ioPB for data transfer tests
;
Setup:
Lea ioPB(A5),A0
Move.L BuffHndl(A5),A1
Move.L (A1),ioBuffer(A0)
Move.L #XferSize,ioReqCount(A0)
Move #fsFromStart,ioPosMode(A0)
;
; Do an initial read to seek to start of volume
; (don't count seek time in transfer tests)
;
Clr.L ioPosOffset(A0)
_Read
Bne Error
;
; Perform data transfer tests: reads
;
MoveQ #TransferCount-1,D1 ;number of iterations, adusted for Dbra
Clr.L D2 ;running total time of test
@0 Sub.L Ticks,D2 ;subtract starting time, this pass
Clr.L ioPosOffset(A0)
_Read
Bne Error
Add.L Ticks,D2 ;add ending time, this pass
Jsr Dither ;dither between passes
Dbra D1,@0
Move.L D2,XferRdTicks(A5)
;
; Perform data transfer tests: writes
;
MoveQ #TransferCount-1,D1
Clr.L D2
@1 Sub.L Ticks,D2
Clr.L ioPosOffset(A0)
_Write
Bne Error
Add.L Ticks,D2
Jsr Dither
Dbra D1,@1
Move.L D2,XferWtTicks(A5)
;
; Perform access time test (unless volume too small)
;
Tst.B SkipAccess(A5)
Bne.S Results
Move.L #512,ioReqCount(A0) ;read one block at each location
MoveQ #AccessCount-1,D1 ;number of iterations, adjusted for Dbra
Clr.L D2
@2 Sub.L Ticks,D2
Move.L #1024*1024,ioPosOffset(A0)
_Read
Bne Error
Clr.L ioPosOffset(A0)
_Read
Bne Error
Add.L Ticks,D2
Jsr Dither
Dbra D1,@2
Move.L D2,AccessTicks(A5)
;
; Convert results to ASCII and call ParamText with resulting strings
;
Results:
Move.L XferRdTicks(A5),D0
Lea XferRdStr(A5),A0
Move.L A0,-(SP)
Clr -(SP) ;NumToString
_Pack7
Move.L XferWtTicks(A5),D0
Lea XferWtStr(A5),A0
Move.L A0,-(SP)
Clr -(SP) ;NumToString
_Pack7
Pea '(Volume too small)' ;assume no access test was done
Tst.B SkipAccess(A5)
Bne.S @0 ;correct
Move.L AccessTicks(A5),D0
Lea AccessStr(A5),A0
Move.L A0,(SP)
Clr -(SP) ;NumToString
_Pack7
@0 Clr.L -(SP)
_ParamText
;
; Take down "Please wait" and put up results dialog
;
Move.L DlogPtr(A5),-(SP)
_DisposDialog
SubQ #4,SP
Move #ResultsDlogID,-(SP)
Clr.L -(SP)
MoveQ #-1,D0
Move.L D0,-(SP)
_GetNewDialog ;just leave result on stack
;
; Wait for OK button, then quit
;
_InitCursor
SubQ #2,SP ;space for itemHit
Clr.L -(SP) ;filterProc
Pea 4(SP) ;addr of itemHit
_ModalDialog
_ExitToShell
;
; Display cause of fatal error and quit
; D0 = error code
;
Error: Lea ErrorStr(A5),A0
Move.L A0,-(SP) ;for ParamText
Ext.L D0
Clr -(SP)
_Pack7 ;convert error code to ASCII
Clr.L -(SP)
Clr.L -(SP)
Clr.L -(SP)
_ParamText
Move.L DlogPtr(A5),-(SP) ;take down "Please wait"...
_DisposDialog
_InitCursor
SubQ #2,SP
Move #ErrorAlertID,-(SP)
Clr.L -(SP)
_StopAlert
_ExitToShell
; Dither: Waste some time to remove rotational positioning bias.
; A hard disk typically rotates a couple thousand RPM, which
; is about .5 to 1 rotations per tick. A loop with _GetNextEvent
; goes about 5 iterations per tick, so a delay of 1 to 64 iterations
; will hold us up from zero to 12 ticks - plenty of time to randomize
; the disk's rotational position.
; EMV April 9, 1986
Dither
Movem.L D1-D2/A0,-(SP) ; save registers used in test loop
Clr.W -(SP) ; for random integer
_Random
Move.W (SP)+,D3 ; -32767 <= D3 <= 32767
And.L #63,D3 ; 0 <= D3 <= 63
DitherLoop
Clr.W -(SP) ; for result of _GetNextEvent
Move.W #-1,-(SP) ; any event is acceptable
Pea EventRecord ; place to store event
_GetNextEvent
Tst.W (SP)+ ; discard result
Dbra D3,DitherLoop ; just get another event
Movem.L (SP)+,D1-D2/A0 ; restore registers
Rts
EventRecord
Dcb.B evtBlkSize,0 ; space for event record
End